import axios from "axios";

import { config } from "./config";

const { result_code, base_url, request_timeout } = config;

// 请求白名单，无须token的接口
const whiteList: string[] = ["/login"];
const service = axios.create({
  baseURL: base_url,
  timeout: request_timeout,
});

//添加请求拦截
service.interceptors.request.use(
  (config) => {
    console.log("请求被拦截");
    return config;
  },
  (error) => {},
);
//添加响应拦截
service.interceptors.response.use(
  (res) => {
    console.log("响应被拦截");
    return res.data;
  },
  (error) => {
    return error;
  },
);

export default service;
